package com.cdwm.mrp.controller.view;

import com.cdwm.mrp.domain.po.Customer;
import com.cdwm.mrp.service.CustomerSerivce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @version v1.0
 * @Author: lyw
 * @Date: 2021/8/4
 */
@Controller
@RequestMapping("/customer")
public class CustomerControllerView {
    @Autowired
    private CustomerSerivce customerSerivce;

    @GetMapping("/view/system/customerView")
    public String customerMainView(){
        return "view/system/customer/customer";
    }

    @GetMapping("/view/system/add")
    public String addCustomerView(){
        return "view/system/customer/add";
    }

    @GetMapping("/view/system/edit/{id}")
    public String editCustomerView(@PathVariable Long id, Model model){
        Customer customer = customerSerivce.getById(id);
        model.addAttribute("customer",customer);
        return "view/system/customer/edit";
    }
}
